from django.apps import AppConfig
from django.conf import settings
from django.db import connection
from elasticsearch.dsl.connections import connections

class SearchConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'search'


    # 重写初始化ready方法：app是子应用的入口
    def ready(self):
        connections.configure(
            default={
                'hosts': settings.ELASTICSEARCH_DSL['default']['hosts'],
                'timeout': 20,
                "verify_certs": False
            }
        )
